﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RunUOGenerator
{
    public partial class ComboControl : BaseTabControl
    {
        private List<BaseValueType> baseValueTypes = new List<BaseValueType>();

        public ComboControl()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Sets or gets the width of this control.
        /// </summary>
        public override int Width
        {
            set
            {
                base.Width = value + 10;

                comboBox.Width = value;
                //this.Size = new Size(value + 2, this.Size.Height);
            }
            get { return this.Size.Width; }
        }

        public void AddItem(string nameVal, string baseVal)
        {
            comboBox.Items.Add(nameVal);
            baseValueTypes.Add(new BaseValueType(nameVal, baseVal));
        }

        public void RemoveAllItems()
        {
            comboBox.Items.Clear();
        }

        private void comboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            foreach(BaseValueType type in baseValueTypes)
            {
                if (comboBox.SelectedItem.ToString() == type.Name)
                {
                    this.Value = type.Base;
                    return;
                }
            }

           // this.Value = comboBox.SelectedItem.ToString();
        }

        private class BaseValueType
        {
            public string Name = "";
            public string Base = "";

            public BaseValueType(string nameVal, string baseVal)
            {
                Name = nameVal;
                Base = baseVal;
            }
        }
    }
}
